/**
 * 
 */
package lt.vin.exaatto.client.ui;

import lt.vin.exaatto.client.events.UserInfoAvailableHandler;
import lt.vin.exaatto.shared.UserInformation;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author Vincentas
 *
 */
public class ContainerWidget<T> extends Composite implements UserInfoAvailableHandler {

	private static ContainerWidgetUiBinder uiBinder = GWT.create(ContainerWidgetUiBinder.class);

	interface ContainerWidgetUiBinder extends UiBinder<Widget, ContainerWidget> {
	}
		
	@UiField
	Anchor logout;
	
	public ContainerWidget() {
		initWidget(uiBinder.createAndBindUi(this));
		
		Stat.getHandlerManager().addHandler(UserInfoAvailableHandler.type, this);
	}

	@Override
	public void userInfoAvailable(UserInformation userInfo) {
		logout.setHref(userInfo.getLogoutUrl());		
	}
}
